package com.bestdreamer.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class ListStreamTest {

    public static void main(String[] args) {

        List<String> ids = new ArrayList<>();
        ids.add("1001");
        ids.add("1002");
        ids.add("1003");
        List<String> list = new ArrayList<>();
        List<User> userList =  new ArrayList<>();
        List<User> users = new ArrayList<>();
        userList.add(new User("1001","hkrong1"));
        userList.add(new User("1002","hkrong2"));
        userList.add(new User("1003","hkrong3"));
        userList.add(new User("1004","hkrong4"));
        users = userList;
        userList = userList.stream().filter(user -> ids.contains(user.getId())).collect(Collectors.toList());
        userList.forEach(user->user.setName(user.getName()+"dd"));
//        userList = userList.stream().filter(user -> ids.contains(user.getId())).collect(Collectors.toList());

        System.out.println(userList.size());
        System.out.println(users.size());
        userList.forEach(user -> list.add(user.getName()));
        System.out.println(list);


    }

    static class User{
        private String id;
        private String name;

        public User(){}

        public User(String id,String name){
            this.id = id;
            this.name = name;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
